home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / Draw / Sources / InsrtCmd.cpp < prev    next >
Encoding:
Text File  |  1996-08-16  |  3.8 KB  |  125 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                InsrtCmd.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #include "ODFDraw.hpp"
  13.  
  14. #ifndef INSERTCMD_H
  15. #include "InsrtCmd.h"
  16. #endif
  17.  
  18. #ifndef DRAWSEL_H
  19. #include "DrawSel.h"
  20. #endif
  21.  
  22. #ifndef DRAWFRM_H
  23. #include "DrawFrm.h"
  24. #endif
  25.  
  26. #ifndef DRAWCONT_H
  27. #include "DrawCont.h"
  28. #endif
  29.  
  30. //========================================================================================
  31. // RunTime Info
  32. //========================================================================================
  33.  
  34. #ifdef FW_BUILD_MAC
  35. #pragma segment odfdrawcommand
  36. #endif
  37.  
  38.  
  39. FW_DEFINE_AUTO(CDrawInsertCommand)
  40.  
  41. //========================================================================================
  42. // CDrawInsertCommand
  43. //========================================================================================
  44.  
  45. //----------------------------------------------------------------------------------------
  46. //    CDrawInsertCommand constructor
  47. //----------------------------------------------------------------------------------------
  48.  
  49. CDrawInsertCommand::CDrawInsertCommand(Environment *ev, 
  50.                                         CDrawFrame* frame, 
  51.                                         const FW_PFileSpecification& fileSpec, 
  52.                                         CDrawSelection* selection,
  53.                                         FW_Boolean canUndo) :
  54.     FW_CInsertCommand(ev, frame, fileSpec, canUndo),
  55.     fUndoContent(NULL),
  56.     fDrawSelection(selection)
  57. {
  58. }
  59.  
  60. //----------------------------------------------------------------------------------------
  61. //    CDrawInsertCommand destructor
  62. //----------------------------------------------------------------------------------------
  63.  
  64. CDrawInsertCommand::~CDrawInsertCommand()
  65. {
  66.     delete fUndoContent;
  67. }
  68.  
  69. //----------------------------------------------------------------------------------------
  70. //    CDrawInsertCommand::PreCommand
  71. //----------------------------------------------------------------------------------------
  72.  
  73. void CDrawInsertCommand::PreCommand(Environment *ev)
  74. {
  75.     fDrawSelection->CloseSelection(ev);
  76. }
  77.  
  78. //----------------------------------------------------------------------------------------
  79. //    CDrawInsertCommand::CommandDone
  80. //----------------------------------------------------------------------------------------
  81.  
  82. void CDrawInsertCommand::CommandDone(Environment *ev)
  83. {
  84.     fDrawSelection->CenterSelection(ev, GetFrame(ev));
  85. }
  86.  
  87. //----------------------------------------------------------------------------------------
  88. //    CDrawInsertCommand::SaveRedoState
  89. //----------------------------------------------------------------------------------------
  90.  
  91. void CDrawInsertCommand::SaveRedoState(Environment *ev)
  92. {
  93.     FW_ASSERT(fUndoContent == NULL);
  94.     fUndoContent = FW_NEW(CDrawUndoContent, (ev, fDrawSelection));
  95. }
  96.  
  97. //----------------------------------------------------------------------------------------
  98. //    CDrawInsertCommand::FreeRedoState
  99. //----------------------------------------------------------------------------------------
  100.  
  101. void CDrawInsertCommand::FreeRedoState(Environment* ev)
  102. {
  103.     fUndoContent->DeleteSavedShapes(ev);
  104. }
  105.  
  106. //----------------------------------------------------------------------------------------
  107. //    CDrawInsertCommand::UndoIt
  108. //----------------------------------------------------------------------------------------
  109.  
  110. void CDrawInsertCommand::UndoIt(Environment *ev)
  111. {
  112.     FW_CInsertCommand::UndoIt(ev);
  113.     fUndoContent->RemoveShapeSelection(ev);
  114. }
  115.  
  116. //----------------------------------------------------------------------------------------
  117. //    CDrawInsertCommand::RedoIt
  118. //----------------------------------------------------------------------------------------
  119.  
  120. void CDrawInsertCommand::RedoIt(Environment *ev)
  121. {
  122.     FW_CInsertCommand::RedoIt(ev);
  123.     fUndoContent->RestoreShapeSelection(ev);
  124. }
  125.